package com.pattern.template;

/**
 * @author Mr.yuan
 * @version v1.0
 * @date 2019/7/25 17:28
 **/
public class TemplatePattern {
    public static void main(String[] args) {
        Game game = new LOL();
        game.play();
        System.out.println();
        game = new DOTA();
        game.play();
    }

    private static abstract class Game {
        abstract void initialize();

        abstract void startPlay();

        abstract void endPlay();

        private final void play() {
            initialize();
            startPlay();
            endPlay();
        }
    }

    private static class LOL extends Game {
        @Override
        void initialize() {
            System.out.println("welcome lol game");
        }

        @Override
        void startPlay() {
            System.out.println("start lol game");
        }

        @Override
        void endPlay() {
            System.out.println("end lol game");
        }
    }

    private static class DOTA extends Game {
        @Override
        void initialize() {
            System.out.println("welcome dota game");
        }

        @Override
        void startPlay() {
            System.out.println("start dota game");
        }

        @Override
        void endPlay() {
            System.out.println("end dota game");
        }
    }
}
